<!DOCTYPE html>
<html>

<body>
    <button onclick="fetchStudents()">获取提交的测试学生数据</button>
    <ul id="studentList"></ul>

    <script>
        // Bmob 初始化
        const Bmob = (window.Bmob = {
            Application_ID: "bcc86d3a5076794cbada268bfc2a79fe",
            REST_API_Key: "42d9429f857a423137ba00bb94422d8d"
        });

        // 获取数据
        async function fetchStudents() {
            const url = "https://api.bmobapp.com/1/classes/Student";

            try {
                const response = await fetch(url, {
                    headers: {
                        "X-Bmob-Application-Id": Bmob.Application_ID,
                        "X-Bmob-REST-API-Key": Bmob.REST_API_Key
                    }
                });

                const students = await response.json();
                const listElement = document.getElementById("studentList");

                students.results.forEach((student) => {
                    const li = document.createElement("li");
                    li.textContent = `${student.name} - 分数: ${student.score}`;
                    listElement.appendChild(li);
                });
            } catch (error) {
                console.error("获取失败:", error);
            }
        }
    </script>
</body>

</html>